<template>
	<div>
		<a-row>
			<a-col span="24">
				<!--            <div id="jsoneditor" ref="jsonEditor" style="width: 100%; height: 600px;"></div>-->
				<ParamDefine
					v-if="props.componentConfig?.output"
					:params="props.componentConfig.output"
					:isViewBasicFieldFlag="false"
					:isViewArrayFlag="true"
					:isAddColumnFlag="false"
					:isActionColumnFlag="false"
					:isUpdateColumnFlag="false"
					:jsonEditorFlag="false"
					:funcFlag="true"
					:isUpdateDefaultValueFlag="true"
					:defaultValueFlag="true"
					:isRemoveColumnFlag="false"
					:isAddChildrenColumnFlag="false"
					:isMappingColumnFlag="false"
					ref="left"
				></ParamDefine>
			</a-col>
		</a-row>
	</div>
</template>
<script setup>
import { onMounted, ref, watch, toRaw, inject, getCurrentInstance } from 'vue'
import { Message, Radio, Row, Switch } from 'view-ui-plus'
import ParamDefine from '@/views/restapi/ParamDefine.vue'
import processVersionContentApi from '@/api/process/processVersionContentApi'

import { mergeStepConfigToFrontFile, hasProperties } from '@/utils'

const props = defineProps(['componentConfig', 'nodeId', 'id', 'frontFile'])

const defaultConfig = () => {
	return {
		output: {
			params: [],
			basicTypeFlag: false,
			isArrayFlag: false
		}
	}
}

const left = ref()

onMounted(async () => {
	if (!hasProperties(props.componentConfig)) {
		const c = defaultConfig()
		props.componentConfig.output = c.output
	}
	await queryOutput()
})

const queryOutput = async () => {
	const c = await getOutputDefine()
	const cb = left.value.repairJson(c)
	props.componentConfig.output = cb
}

const getOutputDefine = async () => {
	//需要调用后端查询接口定义
	const read = await processVersionContentApi.getCurrentOutputDefine({
		id: props.id,
		frontFile: props.frontFile,
		stepCode: props.nodeId
	})
	return read
}
</script>
<style scoped></style>
